import {reactive, ref} from 'vue';
import { defineStore } from 'pinia'

/**
 * 用于存放活动的未读消息
 *
 */

export const useActivityMessage = defineStore(
    'activityMessage',
    () => {

        /**
         * 存放收到的消息
         */
        const activityMessage = new Map()

        const unreadCount = ref(0)

        const setUnreadCount = (value) => {
            unreadCount.value = value;
        }

        const getUnreadCount = () => {
            return unreadCount.value
        }

        const setMessage = (key, value) => {
            activityMessage.set(key, value);
        }
        const getMessage = (key) => {
            activityMessage.get(key);
        }
        const hasMessage = (key) => {
            activityMessage.has(key);
        }
        const deleteMessage = (key) => {
            activityMessage.delete(key);
        }
        const clear = () => {
            activityMessage.clear();
        }

        // const updateJwt = (jwt) => {
        //     jwtEntity.jwt = jwt.jwt;
        //     jwtEntity.signKeyStr = jwt.signKeyStr;
        // }
        // const removeJwt = () => {
        //     jwtEntity.jwt = '';
        //     jwtEntity.signKeyStr = '';
        // }

        return {
            activityMessage,setMessage,getMessage,
            hasMessage,deleteMessage,clear,
            unreadCount,setUnreadCount,getUnreadCount
        }
    }
)